(function(YuXi){
	var appendix={};
	//附件播放
	appendix.get=function(urlObject){
		for(var i=0;i<urlObject.length;i++)
		{
			var url=urlObject[i];
			var length=url.length;
			var length=url.length;
			url=url.substring(1,length-1);
			var last=url.lastIndexOf(".")
			var address=url.substring(last,length);
			var flag=false;
			var olhtml="";
			olhtml=$("ol").html();
			if(olhtml.indexOf("信息详情")>-1||olhtml.indexOf("任务派遣")>-1||olhtml.indexOf("录入任务完成情况")>-1||olhtml.indexOf("信息点评")>-1||olhtml.indexOf("信息评价")>-1||olhtml.indexOf("信息调配")>-1)
			{
				
				flag=true;
			}

			//图片
			if(address==".jpg" || address==".png" || address==".bmp")
			{	
				var html="";
				if(flag)
				{
					html="<div class='appendixcancel'><a class='imag' href='javascript:void();' ><img    style='margin-left:5px; width:200px;height:264px;' src="+url+"></a><a href='#'></a></div> ";
				}
				else
				{
					html="<div class='appendixcancel'><span data-url="+url+" class='glyphicon glyphicon-remove-circle'></span><a class='imag' href='javascript:void();' ><img    style='margin-left:5px; width:200px;height:264px;' src="+url+"></a><a href='#'></a></div> ";
				
				}
				$("#valAppendix").append(html);
			}
			//视频
			else if(address==".mp4" )
			{
				var html="";
				if(flag)
				{
					 html="<div class='appendixcancel'><video style='margin-left:5px;'  id='example_video_1' class='video-js vjs-default-skin' controls preload='none' width='340' height='264' poster='http://video-js.zencoder.com/oceans-clip.png' data-setup='{}'><source src="+url+" type='video/mp4' /></video></div>";
				}
				else
				{
					html="<div class='appendixcancel'><span data-url="+url+" class='glyphicon glyphicon-remove-circle'></span><video style='margin-left:5px;'  id='example_video_1' class='video-js vjs-default-skin' controls preload='none' width='340' height='264' poster='http://video-js.zencoder.com/oceans-clip.png' data-setup='{}'><source src="+url+" type='video/mp4' /></video></div>";
				
				}
				$("#valAppendix").append(html);
			
			}
			else if(address==".rmvb")
			{
				var html="";
				if(flag)
				{
					html="<div class='appendixcancel'><video style='margin-left:5px;'  id='example_video_1' class='video-js vjs-default-skin' controls preload='none' width='340' height='264' poster='http://video-js.zencoder.com/oceans-clip.png' data-setup='{}'><source src="+url+" type='video/rmvb' /></video></div>";
				
				}
				else
				{
					html="<div class='appendixcancel'><span data-url="+url+" class='glyphicon glyphicon-remove-circle'></span><video style='margin-left:5px;'  id='example_video_1' class='video-js vjs-default-skin' controls preload='none' width='340' height='264' poster='http://video-js.zencoder.com/oceans-clip.png' data-setup='{}'><source src="+url+" type='video/rmvb' /></video></div>";
				
				}
				var html="<div class='appendixcancel'><span data-url="+url+" class='glyphicon glyphicon-remove-circle'></span><video style='margin-left:5px;'  id='example_video_1' class='video-js vjs-default-skin' controls preload='none' width='340' height='264' poster='http://video-js.zencoder.com/oceans-clip.png' data-setup='{}'><source src="+url+" type='video/rmvb' /></video></div>";
				$("#valAppendix").append(html);
			}
			else if(address==".avi")
			{
				var html="";
				if(flag)
				{
					var html="<div class='appendixcancel'><video style='margin-left:5px;'  id='example_video_1' class='video-js vjs-default-skin' controls preload='none' width='340' height='264' poster='http://video-js.zencoder.com/oceans-clip.png' data-setup='{}'><source src="+url+" type='video/avi' /></video></div>";
				
				}
				else
				{
					html="<div class='appendixcancel'><span data-url="+url+" class='glyphicon glyphicon-remove-circle'></span><video style='margin-left:5px;'  id='example_video_1' class='video-js vjs-default-skin' controls preload='none' width='340' height='264' poster='http://video-js.zencoder.com/oceans-clip.png' data-setup='{}'><source src="+url+" type='video/avi' /></video></div>";
				
				}
				$("#valAppendix").append(html);
			}
			//音频
			else if(address==".mp3")
			{
				var html="";
				if(flag)
				{
					html="<div class='appendixcancel'><video style='margin-left:5px;'  id='example_video_1' class='video-js vjs-default-skin' controls preload='none' width='340' height='264' poster='http://video-js.zencoder.com/oceans-clip.png' data-setup='{}'><source src="+url+" type='video/mp3' /></video></div>";
				
				}
				else
				{
					html="<div class='appendixcancel'><span data-url="+url+" class='glyphicon glyphicon-remove-circle'></span><video style='margin-left:5px;'  id='example_video_1' class='video-js vjs-default-skin' controls preload='none' width='340' height='264' poster='http://video-js.zencoder.com/oceans-clip.png' data-setup='{}'><source src="+url+" type='video/mp3' /></video></div>";
				
				}
				$("#valAppendix").append(html);
			}
			else if(address==".wav")
			{
				var html="";
				if(flag)
				{
						html="<div class='appendixcancel'><video style='margin-left:5px;'  id='example_video_1' class='video-js vjs-default-skin' controls preload='none' width='340' height='264' poster='http://video-js.zencoder.com/oceans-clip.png' data-setup='{}'><source src="+url+" type='video/wav' /></video></div>";
				
				}
				else
				{
					html="<div class='appendixcancel'><span data-url="+url+" class='glyphicon glyphicon-remove-circle'></span><video style='margin-left:5px;'  id='example_video_1' class='video-js vjs-default-skin' controls preload='none' width='340' height='264' poster='http://video-js.zencoder.com/oceans-clip.png' data-setup='{}'><source src="+url+" type='video/wav' /></video></div>";
				
				}
				$("#valAppendix").append(html);
			}
			
			//其他文件
			else
			{
				var name=url.substring(url.lastIndexOf("/")+1);
				var html="";
				if(flag)
				{
					html="<div class='appendixcancel'><a href='"+url+"'>"+name+"</a></div><br>";
				
				}
				else
				{
					html="<div class='appendixcancel'><span data-url="+url+" class='glyphicon glyphicon-remove-circle'></span><a href='"+url+"'>"+name+"</a></div><br>";
				
				}
				
				$("#valAppendix").append(html);
			}
		} 
		
		show();
	}


	
	var left="";
	var right="";
	var nowpage=0;
	var imgLength=0;
	function show()
	{
		imgLength=$("#valAppendix").find(".imag").length*2;
		
		if(imgLength>1)
		{
			left='<div style="position:absolute;top:50%;left:10%;" id="leftimg" ><span class="glyphicon glyphicon-menu-left" aria-hidden="true"></span></div>';
			right='<div style="position:absolute;top:50%;;right:10%;" id="rightimg"><span class="glyphicon glyphicon-menu-right" aria-hidden="true"></span></div>';
		}
		var hei=$(document.body).height();
		$(".imag").click(function(){
			var src=$(this).find("img").attr("src");
			src="<img id='nowimg' style='width:60%;height:60%;max-width:80%;max-height:800px;' src='"+src+"'>";
			nowpage= $(this).index();

			var html="<div id='imm' style='width:100%;color:#ffffff;height:"+hei+"px;position:absolute;top:0px;z-index:99999;background-color:#191919;'><div id='imgmo' align='center' style='width:80%;padding-top:10%; height:100%;position:absolute;top:0px;left:10%;z-index:999;background-color:#000000;font-size:30px;'>"+left+right+"<div style='width:100%;height:40px;font-size:30px;padding-right:100px;text-align:right;position:relative;'><span style='margin-right:5%;margin-top:-100px;' id='imagAdd' class='glyphicon glyphicon-plus' aria-hidden='true'></span><span style='margin-right:5%;margin-top:-100px;' id='imagmul' class='glyphicon glyphicon-minus' aria-hidden='true'></span><span style='margin-right:15%;margin-top:-100px;' id='imagCancel' class='glyphicon glyphicon-remove-circle' aria-hidden='true'></span></div>"+src+"</div></div>";
			$(".container-fuild").append(html);
			/*score();//禁用滚动条*/
			clickimg();
		})
	}
	function clickimg()
	{
		var flag=0;//判断点击遮罩是否隐藏
		$("#imagCancel").click(function(){
			$("#imm").remove();
		/*	 $ (window).unbind ('scroll');*///滚动条可用
		})
		
		$("#leftimg").click(function(){
			nowpage=nowpage-2;
			if(nowpage<0)
			{
				nowpage=imgLength-2;
			}
			var src=$("#valAppendix").find("a").eq(nowpage).find("img").attr("src");
			
			src="<img id='nowimg' style='width:60%;height:60%;max-width:80%;max-height:800px;' src='"+src+"'>";
			
			$("#nowimg").remove();
			$("#imgmo").append(src);
			flag=1;
		})
		$("#rightimg").click(function(){
			nowpage=nowpage+2;
			if(nowpage>imgLength-1)
			{
				nowpage=0;
			}
			var src=$("#valAppendix").find("a").eq(nowpage).find("img").attr("src");
		
			src="<img id='nowimg' style='width:60%;height:60%;max-width:80%;max-height:800px;' src='"+src+"'>";
			$("#nowimg").remove();

			$("#imgmo").append(src);
			flag=1;
		})
		//－按钮
		$("#imagmul").click(function(){
			var width=parseInt($("#imgmo").find("img").css("width"));
			var height=parseInt($("#imgmo").find("img").css("height"));
			if(width>=300)
			{
				width=width-50+"px";
				height=height-50+"px";
				$("#imgmo").find("img").css("width",width);
				$("#imgmo").find("img").css("height",height);
				
			}
			flag=1;
			
		})
		//+按钮
		$("#imagAdd").click(function(){
			var width=parseInt($("#imgmo").find("img").css("width"));
			var height=parseInt($("#imgmo").find("img").css("height"));
				width=width+50+"px";
				height=height+50+"px";
				$("#imgmo").find("img").css("width",width);
				$("#imgmo").find("img").css("height",height);
			flag=1;
		})
		$("#imm").click(function(){
			if(flag==0)
			{
				$("#imm").remove();
			/* $ (window).unbind ('scroll');*/
			 
			}
			flag=0;
			
		})
	}
	//禁用滚动条
	/*function score()
	{
		jQuery(window).scroll(function(){
	    jQuery(window).scrollTop(0);
	    $ ("#imm").unbind ('scroll');
		});
	}*/

	
	YuXi.appendix=appendix;
})(window.YuXi)
